﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QuanLyThuVien.VO;

namespace QuanLyThuVien
{
    public partial class frmChinh : Form
    {
        public static NguoiDung NguoiDung;

        public void thietLapHienThiMenu(bool DangNhap,
                                    bool ThayMatKhau,
                                    bool DangKy,
                                    bool QuanLyNguoiDung,
                                    bool QuanLySach,
                                    bool QuanLyDocGia,
                                    bool QuanLyThongTinMuonTra,
                                    bool DangXuat)
        {
            dangNhapToolStripMenuItem.Visible = DangNhap;
            thayMatKhauToolStripMenuItem.Visible = ThayMatKhau;
            dangKyToolStripMenuItem.Visible = DangKy;
            quanLyNguoiDungToolStripMenuItem.Visible = QuanLyNguoiDung;
            sachToolStripMenuItem.Visible = QuanLySach;
            quanLyDocGiaToolStripMenuItem.Visible = QuanLyDocGia;
            quanLyThongTinMuonTraToolStripMenuItem.Visible = QuanLyThongTinMuonTra;
            dangXuatToolStripMenuItem.Visible = DangXuat;
        }


        public frmChinh()
        {
            InitializeComponent();
            thietLapHienThiMenu(true, false, true, false, false, false,
                                false, false);
        }

        private void dangNhapToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmDangNhap frmDangNhap = new frmDangNhap();
            frmDangNhap.ShowDialog();
            if (frmDangNhap.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                thietLapHienThiMenu(false, true, false, NguoiDung.QuyenQuanLyNguoiDung,
                                    NguoiDung.QuyenQuanLySach, NguoiDung.QuyenQuanLyDocGia,
                                    NguoiDung.QuyenQuanLyThongTinMuonTra, true);
            }
        }

        private void dangXuatToolStripMenuItem_Click(object sender, EventArgs e)
        {
            thietLapHienThiMenu(true, false, true, false, false, false,
                                false, false);
            NguoiDung = null;
        }

        private void suaSachToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmSuaSach frmSuaSach = new frmSuaSach();
            frmSuaSach.ShowDialog();
        }

        private void timKiemSachToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmTimKiemSach frmTimKiemSach = new frmTimKiemSach();
            frmTimKiemSach.ShowDialog();
        }

        private void themSachToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmThemSach frmThemSach = new frmThemSach();
            frmThemSach.ShowDialog();
        }

        private void xoaSachToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmXoaSach frmXoaSach = new frmXoaSach();
            frmXoaSach.ShowDialog();
        }

        private void themDocGiaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmThemDocGia frmThemDocGia = new frmThemDocGia();
            frmThemDocGia.ShowDialog();
        }

        private void suaDocGiaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmSuaDocGia frmSuaDocGia = new frmSuaDocGia();
            frmSuaDocGia.ShowDialog();
        }

        private void xoaDocGiaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmXoaDocGia frmXoaDocGia = new frmXoaDocGia();
            frmXoaDocGia.ShowDialog();
        }

        private void timKiemDocGiaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmTimKiemDocGia frmTimKiemDocGia = new frmTimKiemDocGia();
            frmTimKiemDocGia.ShowDialog();
        }

        private void themToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmThemMuonTra frmThemMuonTra = new frmThemMuonTra();
            frmThemMuonTra.ShowDialog();
        }

        private void timKiemToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmTimKiemMuonTra frmTimKiemMuonTra = new frmTimKiemMuonTra();
            frmTimKiemMuonTra.ShowDialog();
        }

        private void huongDanSuDungToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmHuongDanSuDung frmHuongDanSuDung = new frmHuongDanSuDung();
            frmHuongDanSuDung.ShowDialog();
        }

        private void thongTinLienHeToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void thayMatKhauToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmThayMatKhau frmThayMatKhau = new frmThayMatKhau();
            frmThayMatKhau.ShowDialog();
        }

        private void dangKyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmDangKy frmDangKy = new frmDangKy();
            frmDangKy.ShowDialog();
        }

        private void xoaNguoiDungToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmXoaNguoiDung frmXoaNguoiDung = new frmXoaNguoiDung();
            frmXoaNguoiDung.ShowDialog();
        }

        private void chinhSuaQuyenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmSuaQuyenNguoiDung frmSuaQuyenNguoiDung = new frmSuaQuyenNguoiDung();
            frmSuaQuyenNguoiDung.ShowDialog();
        }

        private void frmChinh_Load(object sender, EventArgs e)
        {

        }
    }
}
